package com.tedu.openmedical.medicalsystem.ICD10.controller;

import com.tedu.openmedical.base.response.JsonResult;
import com.tedu.openmedical.medicalsystem.ICD10.dto.ICDQuery;
import com.tedu.openmedical.medicalsystem.ICD10.dto.ICDSaveParam;
import com.tedu.openmedical.medicalsystem.ICD10.service.ICDService;
import com.tedu.openmedical.medicalsystem.ICD10.vo.ICDVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/v1/ICD/")
@Slf4j
@Api(tags = "ICD管理")
public class ICDController {

    @Autowired
    private ICDService ICDService;

    @GetMapping("select")
    @ApiOperation(value = "查询ICD列表", notes = "查询ICD列表")
    public JsonResult select(ICDQuery query) {
        log.debug("查询ICD列表:{}", query);
        List<ICDVO> ICDvoList =  ICDService.select(query);
        return JsonResult.ok(ICDvoList);
    }

    @PostMapping("save")
    @ApiOperation(value = "保存ICD", notes = "保存ICD")
    public JsonResult save(ICDSaveParam ICDSaveParam) {
        log.debug("保存ICD:{}", ICDSaveParam);
        ICDService.save(ICDSaveParam);
        return JsonResult.ok();
    }

    @GetMapping("delete")
    @ApiOperation(value = "删除ICD", notes = "删除ICD")
    public JsonResult delete(Long id) {
        log.debug("删除ICD:{}", id);
        ICDService.delete(id);
        return JsonResult.ok();
    }
}
